#include <iostream>
#include <string>
#include <version>
#include <algorithm>
using namespace std;

struct stu
{
public:
    string name;  // 名字
    string skill; // 技能
    long int ATK; // 战力
    int id;       // 学号

public:
    stu() {}

    stu(string name, string skill, long int ATK, int id) : name(name), skill(skill), ATK(ATK), id(id) {}
};

// 函数指针 传递给 for_each
void printf_func(stu val)
{
    stu temp = val;
    cout << "姓名:" << temp.name << "\t技能:" << temp.skill << "\t\t战力:" << temp.ATK << "\t\t学号:" << temp.id << endl;
}

stu transform_func(stu val)
{
    return val;
}

int main(int argc, char const *argv[])
{
    // 创建容器
    vector<stu> s1;
    // s2 需要提前扩容
    vector<stu> s2(20);
    s1.push_back(stu("唐三", "蓝银缠绕", 100, 1));
    s1.push_back(stu("萧炎", "佛怒火莲", 500, 2));
    s1.push_back(stu("林动", "大荒囚天指", 9000, 3));
    s1.push_back(stu("牧尘", "灵阵,起!!!", 9001, 4));
    s1.push_back(stu("陈平安", "妈来!!!", 109, 5));
    s1.push_back(stu("荒天帝", "六道轮回", 99999, 5));

    // 将 s1 的所有数据 存储到 s2中
    transform(s1.begin() , s1.end() , s2.begin() , transform_func );

    // 遍历 s2
    for_each(s2.begin(), s2.end(), [&](stu val)
             {
                 stu temp = val;
                 cout << "姓名:" << temp.name << "\t技能:" << temp.skill << "\t\t战力:" << temp.ATK << "\t\t学号:" << temp.id << endl;
             });

    return 0;
}
